package com.teach.basic.model.dto;

import com.common.bean.QueryCondition;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.Min;
import java.io.Serializable;

public class DTO<T>implements Serializable {
    private T model;
    @ApiModelProperty(name = "page",value = "页码",required = false)
    private Integer page;

    @Min(value = 5,message = "分页至少为5")
    private Integer pageSize;

    private String sidx;

    private String order;

    private String asc = "asc";

    private String key;

    public DTO(T model, QueryCondition queryCondition) {

        this.model = model;
        if (queryCondition.getAsc().equals("desc")){
            this.setAsc(queryCondition.getAsc());
        }
        this.setKey(queryCondition.getKeyword());
        this.setOrder(queryCondition.getOrder());
        this.setPage(queryCondition.getPage());
        this.setPageSize(queryCondition.getPageSize());
        this.setSidx(queryCondition.getSidx());
    }

    public T getModel() {
        return model;
    }

    public void setModel(T model) {
        this.model = model;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getSidx() {
        return sidx;
    }

    public void setSidx(String sidx) {
        this.sidx = sidx;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public String getAsc() {
        return asc;
    }

    public void setAsc(String asc) {
        this.asc = asc;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}
